home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / term-source.lha / Extras / Source / term-Source.lha / SerialPanel.c < prev    next >
C/C++ Source or Header  |  1995-07-04  |  17KB  |  710 lines

  1. /*
  2. **    SerialPanel.c
  3. **
  4. **    Editing panel for serial configuration
  5. **
  6. **    Copyright © 1990-1995 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12. enum    {    GAD_BAUD=1000,GAD_DATABITS,GAD_PARITY,GAD_STOPBITS,GAD_HANDSHAKING,GAD_DUPLEX,GAD_BUFFERSIZE,GAD_BREAKLENGTH,
  13.         GAD_STRIP,GAD_HIGHSPEED,GAD_CHECK_CARRIER,GAD_SHARED,GAD_XON_XOFF,GAD_PASSTHROUGH,
  14.         GAD_DEVICE,GAD_SELECT,GAD_UNIT,GAD_QUANTUM,GAD_USE_OWNDEVUNIT,
  15.         GAD_SATISFY_ODU,GAD_USE,GAD_CANCEL,GAD_DEFAULT,
  16.         GAD_PAGER,GAD_PAGEGROUP,GAD_DIRECT_CONNECTION
  17.     };
  18.  
  19. STATIC LONG Sizes[] =
  20. {
  21.     16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288
  22. };
  23.  
  24. STATIC LONG __saveds
  25. ShowBaud(struct Gadget *SomeGadget,WORD Level)
  26. {
  27.     return(BaudRates[Level]);
  28. }
  29.  
  30. STATIC LONG __saveds
  31. ShowSize(struct Gadget *SomeGadget,WORD Level)
  32. {
  33.     return(Sizes[Level]);
  34. }
  35.  
  36. STATIC LONG __saveds __asm
  37. RateHookFunc(register __a2 LONG Current,register __a1 LONG Command)
  38. {
  39.     LONG Index;
  40.  
  41.     if(Current < BaudRates[0])
  42.         Current = BaudRates[Index = 0];
  43.     else
  44.     {
  45.         if(Current > BaudRates[NumBaudRates - 1])
  46.             Current = BaudRates[Index = NumBaudRates - 1];
  47.         else
  48.         {
  49.             LONG i;
  50.  
  51.             Index = -1;
  52.  
  53.             for(i = 0 ; i < NumBaudRates ; i++)
  54.             {
  55.                 if(Current == BaudRates[i])
  56.                 {
  57.                     switch(Command)
  58.                     {
  59.                         case INCREMENTERMSG_DECREMENT:
  60.  
  61.                             if(i > 0)
  62.                                 return(BaudRates[i - 1]);
  63.                             else
  64.                                 return(Current);
  65.  
  66.                         case INCREMENTERMSG_INCREMENT:
  67.  
  68.                             if(i < NumBaudRates - 1)
  69.                                 return(BaudRates[i + 1]);
  70.                             else
  71.                                 return(Current);
  72.  
  73.                         default:
  74.  
  75.                             return(Current);
  76.                     }
  77.                 }
  78.             }
  79.  
  80.             if(Index == -1)
  81.             {
  82.                 if(Command == INCREMENTERMSG_DECREMENT)
  83.                 {
  84.                     for(i = 0 ; i < NumBaudRates ; i++)
  85.                     {
  86.                         if(BaudRates[i] <= Current)
  87.                             Index = i;
  88.                     }
  89.  
  90.                     if(BaudRates[Index] < Current || !Index)
  91.                         return(BaudRates[Index]);
  92.                     else
  93.                         return(BaudRates[Index - 1]);
  94.                 }
  95.                 else
  96.                 {
  97.                     for(i = NumBaudRates - 1 ; i >= 0 ; i--)
  98.                     {
  99.                         if(BaudRates[i] >= Current)
  100.                             Index = i;
  101.                     }
  102.  
  103.                     if(Command == INCREMENTERMSG_INITIAL)
  104.                     {
  105.                         if(Index == -1)
  106.                             return(Current);
  107.                         else
  108.                             return(BaudRates[Index]);
  109.                     }
  110.                     else
  111.                     {
  112.                         if(BaudRates[Index] > Current || Index == NumBaudRates - 1)
  113.                             return(BaudRates[Index]);
  114.                         else
  115.                             return(BaudRates[Index + 1]);
  116.                     }
  117.                 }
  118.             }
  119.         }
  120.     }
  121.  
  122.     if(Index == -1 || (Command != INCREMENTERMSG_DECREMENT && Command != INCREMENTERMSG_INCREMENT))
  123.         return(Current);
  124.     else
  125.     {
  126.         if(Command == INCREMENTERMSG_DECREMENT)
  127.         {
  128.             if(Index > 0)
  129.                 return(BaudRates[Index - 1]);
  130.             else
  131.                 return(BaudRates[Index]);
  132.         }
  133.         else
  134.         {
  135.             if(Index < NumBaudRates - 1)
  136.                 return(BaudRates[Index + 1]);
  137.             else
  138.                 return(BaudRates[Index]);
  139.         }
  140.     }
  141. }
  142.  
  143. BYTE __regargs
  144. SerialPanel(struct Configuration *LocalConfig,BYTE *Default)
  145. {
  146.     STATIC struct Hook IncrementerHook =
  147.     {
  148.         {NULL},
  149.         (HOOKFUNC)RateHookFunc
  150.     };
  151.  
  152.     STATIC LONG PageTitleID[5] =
  153.     {
  154.         MSG_V36_0171,
  155.         MSG_V36_0176,
  156.         MSG_ODU_SUPPORT_TXT,
  157.         MSG_V36_0179,
  158.         -1
  159.     };
  160.  
  161.     STATIC BYTE         InitialPage = 0;
  162.  
  163.     struct LayoutHandle    *Handle;
  164.     BYTE             Cancel = FALSE;
  165.     STRPTR             PageTitle[5];
  166.  
  167.     LocalizeStringTable(PageTitle,PageTitleID);
  168.  
  169.     SaveConfig(LocalConfig,PrivateConfig);
  170.  
  171.     if(Handle = LT_CreateHandleTags(Window -> WScreen,
  172.         LH_LocaleHook,    &LocaleHook,
  173.         LH_ExitFlush,    FALSE,
  174.     TAG_DONE))
  175.     {
  176.         struct Window    *PanelWindow;
  177.         LONG         Rate,Size,Quantum,Bits,StopBits,i;
  178.  
  179.         for(i = 0 ; i < NumBaudRates ; i++)
  180.         {
  181.             if(LocalConfig -> SerialConfig -> BaudRate == BaudRates[i])
  182.             {
  183.                 Rate = i;
  184.  
  185.                 break;
  186.             }
  187.         }
  188.  
  189.         for(i = 4 ; i < sizeof(Sizes) / sizeof(LONG) ; i++)
  190.         {
  191.             if(LocalConfig -> SerialConfig -> SerialBufferSize == Sizes[i])
  192.             {
  193.                 Size = i;
  194.  
  195.                 break;
  196.             }
  197.         }
  198.  
  199.         for(i = 0 ; i < sizeof(Sizes) / sizeof(LONG) ; i++)
  200.         {
  201.             if(LocalConfig -> SerialConfig -> Quantum == Sizes[i])
  202.             {
  203.                 Quantum = i;
  204.  
  205.                 break;
  206.             }
  207.         }
  208.  
  209.         if(LocalConfig -> SerialConfig -> HighSpeed)
  210.         {
  211.             LocalConfig -> SerialConfig -> BitsPerChar    = 8;
  212.             LocalConfig -> SerialConfig -> StopBits    = 1;
  213.             LocalConfig -> SerialConfig -> Parity    = PARITY_NONE;
  214.         }
  215.  
  216.         LT_New(Handle,
  217.             LA_Type,    VERTICAL_KIND,
  218.         TAG_DONE);
  219.         {
  220.             LT_New(Handle,
  221.                 LA_Type,VERTICAL_KIND,
  222.             TAG_DONE);
  223.             {
  224.                 LT_New(Handle,
  225.                     LA_Type,    CYCLE_KIND,
  226.                     LA_ID,        GAD_PAGER,
  227.                     LA_LabelID,    MSG_XFER_PAGE_TXT,
  228.                     GTCY_Labels,    PageTitle,
  229.                     LACY_AutoPageID,GAD_PAGEGROUP,
  230.                     LACY_TabKey,    TRUE,
  231.                     LA_BYTE,    &InitialPage,
  232.                 TAG_DONE);
  233.  
  234.                 LT_EndGroup(Handle);
  235.             }
  236.  
  237.             LT_New(Handle,
  238.                 LA_Type,    VERTICAL_KIND,
  239.                 LA_ID,        GAD_PAGEGROUP,
  240.                 LAGR_Frame,    TRUE,
  241.                 LAGR_ActivePage,InitialPage,
  242.             TAG_DONE);
  243.             {
  244.                 LT_New(Handle,
  245.                     LA_Type,    VERTICAL_KIND,
  246.                 TAG_DONE);
  247.                 {
  248.                     LT_New(Handle,
  249.                         LA_Type,        INTEGER_KIND,
  250.                         LA_LabelID,        MSG_SERIALPANEL_BAUD_RATE_GAD,
  251.                         LA_LONG,        &LocalConfig -> SerialConfig -> BaudRate,
  252.                         LA_ID,            GAD_BAUD,
  253.                         GTIN_MaxChars,        8,
  254.                         LAIN_Min,        0,
  255.                         LAIN_UseIncrementers,    TRUE,
  256.                         LAIN_IncrementerHook,    &IncrementerHook,
  257.                     TAG_DONE);
  258.  
  259.                     Bits = LocalConfig -> SerialConfig -> BitsPerChar - 7;
  260.  
  261.                     LT_New(Handle,
  262.                         LA_Type,        CYCLE_KIND,
  263.                         LA_ID,            GAD_DATABITS,
  264.                         LA_LabelID,        MSG_SERIALPANEL_BITS_PER_CHAR_GAD,
  265.                         LA_LONG,        &Bits,
  266.                         GA_Disabled,        LocalConfig -> SerialConfig -> HighSpeed,
  267.                         LACY_FirstLabel,    MSG_SERIALPANEL_SEVEN_BITS_TXT,
  268.                         LACY_LastLabel,        MSG_SERIALPANEL_EIGHT_BITS_TXT,
  269.                     TAG_DONE);
  270.  
  271.                     LT_New(Handle,
  272.                         LA_Type,        CYCLE_KIND,
  273.                         LA_ID,            GAD_PARITY,
  274.                         LA_LabelID,        MSG_SERIALPANEL_PARITY_GAD,
  275.                         LA_BYTE,        &LocalConfig -> SerialConfig -> Parity,
  276.                         GA_Disabled,        LocalConfig -> SerialConfig -> HighSpeed,
  277.                         LACY_FirstLabel,    MSG_SERIALPANEL_NO_PARITY_TXT,
  278.                         LACY_LastLabel,        MSG_SERIALPANEL_SPACE_TXT,
  279.                     TAG_DONE);
  280.  
  281.                     StopBits = LocalConfig -> SerialConfig -> StopBits - 1;
  282.  
  283.                     LT_New(Handle,
  284.                         LA_Type,        CYCLE_KIND,
  285.                         LA_ID,            GAD_STOPBITS,
  286.                         LA_LabelID,        MSG_SERIALPANEL_STOP_BITS_GAD,
  287.                         LA_LONG,        &StopBits,
  288.                         GA_Disabled,        LocalConfig -> SerialConfig -> HighSpeed,
  289.                         LACY_FirstLabel,    MSG_SERIALPANEL_ONE_BIT_TXT,
  290.                         LACY_LastLabel,        MSG_SERIALPANEL_TWO_BITS_TXT,
  291.                     TAG_DONE);
  292.  
  293.                     LT_New(Handle,
  294.                         LA_Type,        CYCLE_KIND,
  295.                         LA_LabelID,        MSG_SERIALPANEL_HANDSHAKING_GAD,
  296.                         LA_BYTE,        &LocalConfig -> SerialConfig -> HandshakingProtocol,
  297.                         LACY_FirstLabel,    MSG_SERIALPANEL_HANDSHAKING_NONE_TXT,
  298.                         LACY_LastLabel,        MSG_SERIALPANEL_HANDSHAKING_RTS_CTS_DSR_TXT,
  299.                     TAG_DONE);
  300.  
  301.                     LT_New(Handle,
  302.                         LA_Type,        CYCLE_KIND,
  303.                         LA_LabelID,        MSG_SERIALPANEL_DUPLEX_GAD,
  304.                         LA_BYTE,        &LocalConfig -> SerialConfig -> Duplex,
  305.                         LACY_FirstLabel,    MSG_SERIALPANEL_DUPLEX_FULL_TXT,
  306.                         LACY_LastLabel,        MSG_SERIALPANEL_DUPLEX_HALF_TXT,
  307.                     TAG_DONE);
  308.  
  309.                     LT_New(Handle,
  310.                         LA_Type,        SliderType,
  311.                         LA_LabelID,        MSG_SERIALPANEL_BUFFER_SIZE_GAD,
  312.                         LA_LONG,        &Size,
  313.                         GTSL_Min,        4,
  314.                         GTSL_Max,        (sizeof(Sizes) / sizeof(LONG)) - 1,
  315.                         GTSL_DispFunc,        ShowSize,
  316.                         GTSL_LevelFormat,    LocaleBase ? "%7lD" : "%7ld",
  317.                     TAG_DONE);
  318.  
  319.                     LT_New(Handle,
  320.                         LA_Type,        INTEGER_KIND,
  321.                         LA_LabelID,        MSG_SERIALPANEL_BREAK_LENGTH_GAD,
  322.                         LA_LONG,        &LocalConfig -> SerialConfig -> BreakLength,
  323.                         GTIN_MaxChars,        8,
  324.                     TAG_DONE);
  325.  
  326.                     LT_EndGroup(Handle);
  327.                 }
  328.  
  329.                 LT_New(Handle,
  330.                     LA_Type,    VERTICAL_KIND,
  331.                 TAG_DONE);
  332.                 {
  333.                     LT_New(Handle,
  334.                         LA_Type,        CHECKBOX_KIND,
  335.                         LA_LabelID,        MSG_SERIALPANEL_STRIP_BIT_8_GAD,
  336.                         LA_BYTE,        &LocalConfig -> SerialConfig -> StripBit8,
  337.                     TAG_DONE);
  338.  
  339.                     LT_New(Handle,
  340.                         LA_Type,        CHECKBOX_KIND,
  341.                         LA_LabelID,        MSG_SERIALPANEL_SHARED_ACCESS_GAD,
  342.                         LA_BYTE,        &LocalConfig -> SerialConfig -> Shared,
  343.                         LA_ID,            GAD_SHARED,
  344.                     TAG_DONE);
  345.  
  346.                     LT_New(Handle,
  347.                         LA_Type,        CHECKBOX_KIND,
  348.                         LA_LabelID,        MSG_SERIALPANEL_XON_XOFF_GAD,
  349.                         LA_BYTE,        &LocalConfig -> SerialConfig -> xONxOFF,
  350.                     TAG_DONE);
  351.  
  352.                     LT_New(Handle,
  353.                         LA_Type,        CHECKBOX_KIND,
  354.                         LA_LabelID,        MSG_SERIALPANEL_PASS_XON_XOFF_THROUGH_GAD,
  355.                         LA_BYTE,        &LocalConfig -> SerialConfig -> PassThrough,
  356.                     TAG_DONE);
  357.  
  358.                     LT_New(Handle,
  359.                         LA_Type,        CHECKBOX_KIND,
  360.                         LA_LabelID,        MSG_SERIALPANEL_CHECK_CARRIER_GAD,
  361.                         LA_BYTE,        &LocalConfig -> SerialConfig -> CheckCarrier,
  362.                         GA_Disabled,        LocalConfig -> SerialConfig -> DirectConnection,
  363.                         LA_ID,            GAD_CHECK_CARRIER,
  364.                     TAG_DONE);
  365.  
  366.                     LT_New(Handle,
  367.                         LA_Type,        CHECKBOX_KIND,
  368.                         LA_LabelID,        MSG_SERIALPANEL_HIGH_SPEED_MODE_GAD,
  369.                         LA_BYTE,        &LocalConfig -> SerialConfig -> HighSpeed,
  370.                         LA_ID,            GAD_HIGHSPEED,
  371.                     TAG_DONE);
  372.  
  373.                     LT_New(Handle,
  374.                         LA_Type,        CHECKBOX_KIND,
  375.                         LA_LabelID,        MSG_DIRECT_CONNECTION_GAD,
  376.                         LA_BYTE,        &LocalConfig -> SerialConfig -> DirectConnection,
  377.                         LA_ID,            GAD_DIRECT_CONNECTION,
  378.                     TAG_DONE);
  379.  
  380.                     LT_New(Handle,
  381.                         LA_Type,        SliderType,
  382.                         LA_LabelID,        MSG_SERIALPANEL_QUANTUM_GAD,
  383.                         LA_LONG,        &Quantum,
  384.                         LA_Chars,        6,
  385.                         GTSL_Min,        0,
  386.                         GTSL_Max,        (sizeof(Sizes) / sizeof(LONG)) - 1,
  387.                         GTSL_Level,        Quantum,
  388.                         GTSL_DispFunc,        ShowSize,
  389.                         GTSL_LevelFormat,    LocaleBase ? "%7lD" : "%7ld",
  390.                     TAG_DONE);
  391.  
  392.                     LT_EndGroup(Handle);
  393.                 }
  394.  
  395.                 LT_New(Handle,
  396.                     LA_Type,    VERTICAL_KIND,
  397.                 TAG_DONE);
  398.                 {
  399.                     LT_New(Handle,
  400.                         LA_Type,    VERTICAL_KIND,
  401.                     TAG_DONE);
  402.                     {
  403.                         LT_New(Handle,
  404.                             LA_Type,        CHECKBOX_KIND,
  405.                             LA_LabelID,        MSG_SERIALPANEL_USE_OWNDEVUNIT_TXT,
  406.                             LA_BYTE,        &LocalConfig -> SerialConfig -> UseOwnDevUnit,
  407.                             LA_ID,            GAD_USE_OWNDEVUNIT,
  408.                             GA_Disabled,        LocalConfig -> SerialConfig -> Shared,
  409.                         TAG_DONE);
  410.  
  411.                         LT_EndGroup(Handle);
  412.                     }
  413.  
  414.                     LT_New(Handle,
  415.                         LA_Type,    VERTICAL_KIND,
  416.                     TAG_DONE);
  417.                     {
  418.                         LT_New(Handle,
  419.                             LA_Type,        CYCLE_KIND,
  420.                             LA_LabelID,        MSG_SATISFY_ODU_TXT,
  421.                             LA_BYTE,        &LocalConfig -> SerialConfig -> SatisfyODURequests,
  422.                             LA_ID,            GAD_SATISFY_ODU,
  423.                             LACY_FirstLabel,    MSG_SATISFY_ODU_MODE1_TXT,
  424.                             LACY_LastLabel,        MSG_SATISFY_ODU_MODE3_TXT,
  425.                             GA_Disabled,        !LocalConfig -> SerialConfig -> UseOwnDevUnit || LocalConfig -> SerialConfig -> Shared,
  426.                         TAG_DONE);
  427.  
  428.                         LT_EndGroup(Handle);
  429.                     }
  430.  
  431.                     LT_EndGroup(Handle);
  432.                 }
  433.  
  434.                 LT_New(Handle,
  435.                     LA_Type,    VERTICAL_KIND,
  436.                 TAG_DONE);
  437.                 {
  438.                     LT_New(Handle,
  439.                         LA_Type,        STRING_KIND,
  440.                         LA_LabelID,        MSG_SERIALPANEL_SERIAL_DEVICE_GAD,
  441.                         LA_Chars,        20,
  442.                         LA_STRPTR,        LocalConfig -> SerialConfig -> SerialDevice,
  443.                         GTST_MaxChars,        255,
  444.                         LAST_Picker,        TRUE,
  445.                         LA_ID,            GAD_DEVICE,
  446.                     TAG_DONE);
  447.  
  448.                     LT_New(Handle,
  449.                         LA_Type,        INTEGER_KIND,
  450.                         LA_LabelID,        MSG_SERIALPANEL_DEVICE_UNIT_NUMBER_GAD,
  451.                         LA_LONG,        &LocalConfig -> SerialConfig -> UnitNumber,
  452.                         LA_ID,            GAD_UNIT,
  453.                         LAIN_UseIncrementers,    TRUE,
  454.                         GTIN_MaxChars,        8,
  455.                     TAG_DONE);
  456.  
  457.                     LT_EndGroup(Handle);
  458.                 }
  459.  
  460.                 LT_EndGroup(Handle);
  461.             }
  462.  
  463.             LT_New(Handle,
  464.                 LA_Type,VERTICAL_KIND,
  465.             TAG_DONE);
  466.             {
  467.                 LT_New(Handle,
  468.                     LA_Type,    XBAR_KIND,
  469.                     LAXB_FullSize,    TRUE,
  470.                 TAG_DONE);
  471.  
  472.                 LT_EndGroup(Handle);
  473.             }
  474.  
  475.             LT_New(Handle,LA_Type,HORIZONTAL_KIND,
  476.                 LAGR_SameSize,    TRUE,
  477.                 LAGR_Spread,    TRUE,
  478.             TAG_DONE);
  479.             {
  480.                 LT_New(Handle,
  481.                     LA_Type,    BUTTON_KIND,
  482.                     LA_LabelID,    MSG_GLOBAL_USE_GAD,
  483.                     LA_ID,        GAD_USE,
  484.                     LABT_ReturnKey,    TRUE,
  485.                     LABT_ExtraFat,    TRUE,
  486.                 TAG_DONE);
  487.  
  488.                 if(Default)
  489.                 {
  490.                     LT_New(Handle,
  491.                         LA_Type,    BUTTON_KIND,
  492.                         LA_LabelID,    MSG_GLOBAL_DEFAULT_GAD,
  493.                         LA_ID,        GAD_DEFAULT,
  494.                         LABT_ExtraFat,    TRUE,
  495.                     TAG_DONE);
  496.                 }
  497.  
  498.                 LT_New(Handle,
  499.                     LA_Type,    BUTTON_KIND,
  500.                     LA_LabelID,    MSG_GLOBAL_CANCEL_GAD,
  501.                     LA_ID,        GAD_CANCEL,
  502.                     LABT_EscKey,    TRUE,
  503.                     LABT_ExtraFat,    TRUE,
  504.                 TAG_DONE);
  505.  
  506.                 LT_EndGroup(Handle);
  507.             }
  508.  
  509.             LT_EndGroup(Handle);
  510.         }
  511.  
  512.         if(PanelWindow = LT_Layout(Handle,LocaleString(MSG_SERIALPANEL_SERIAL_PREFERENCES_TXT),NULL,0,0,IDCMP_CLOSEWINDOW,0,
  513.             LAWN_HelpHook,        &GuideHook,
  514.             LAWN_Parent,        Window,
  515.             WA_DepthGadget,        TRUE,
  516.             WA_CloseGadget,        TRUE,
  517.             WA_DragBar,        TRUE,
  518.             WA_RMBTrap,        TRUE,
  519.             WA_Activate,        TRUE,
  520.         TAG_DONE))
  521.         {
  522.             UBYTE             DummyBuffer[MAX_FILENAME_LENGTH];
  523.             struct IntuiMessage    *Message;
  524.             BOOLEAN             Done = FALSE;
  525.             ULONG             MsgClass,
  526.                          MsgQualifier;
  527.             UWORD             MsgCode;
  528.             struct Gadget        *MsgGadget;
  529.  
  530.             GuideContext(CONTEXT_SERIAL);
  531.  
  532.             PushWindow(PanelWindow);
  533.  
  534.             LT_ShowWindow(Handle,TRUE);
  535.  
  536.             do
  537.             {
  538.                 if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
  539.                 {
  540.                     SaveConfig(PrivateConfig,LocalConfig);
  541.  
  542.                     break;
  543.                 }
  544.  
  545.                 while(Message = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort))
  546.                 {
  547.                     MsgClass    = Message -> Class;
  548.                     MsgQualifier    = Message -> Qualifier;
  549.                     MsgCode        = Message -> Code;
  550.                     MsgGadget    = (struct Gadget *)Message -> IAddress;
  551.  
  552.                     GT_ReplyIMsg(Message);
  553.  
  554.                     LT_HandleInput(Handle,MsgQualifier,&MsgClass,&MsgCode,&MsgGadget);
  555.  
  556.                     if(MsgClass == IDCMP_CLOSEWINDOW)
  557.                     {
  558.                         SaveConfig(PrivateConfig,LocalConfig);
  559.  
  560.                         Done = TRUE;
  561.                     }
  562.  
  563.                     if(MsgClass == IDCMP_GADGETUP)
  564.                     {
  565.                         switch(MsgGadget -> GadgetID)
  566.                         {
  567.                             case GAD_SHARED:
  568.  
  569.                                 LT_SetAttributes(Handle,GAD_USE_OWNDEVUNIT,
  570.                                     GA_Disabled,LocalConfig -> SerialConfig -> Shared,
  571.                                 TAG_DONE);
  572.  
  573.                                 LT_SetAttributes(Handle,GAD_SATISFY_ODU,
  574.                                     GA_Disabled,!LocalConfig -> SerialConfig -> UseOwnDevUnit || LocalConfig -> SerialConfig -> Shared,
  575.                                 TAG_DONE);
  576.  
  577.                                 break;
  578.  
  579.                             case GAD_USE_OWNDEVUNIT:
  580.  
  581.                                 LT_SetAttributes(Handle,GAD_SATISFY_ODU,
  582.                                     GA_Disabled,!LocalConfig -> SerialConfig -> UseOwnDevUnit || LocalConfig -> SerialConfig -> Shared,
  583.                                 TAG_DONE);
  584.  
  585.                                 break;
  586.  
  587.                             case GAD_HIGHSPEED:
  588.  
  589.                                 if(MsgCode)
  590.                                 {
  591.                                     LT_SetAttributes(Handle,GAD_PARITY,
  592.                                         GA_Disabled,    TRUE,
  593.                                         GTCY_Active,    PARITY_NONE,
  594.                                     TAG_DONE);
  595.  
  596.                                     LT_SetAttributes(Handle,GAD_STOPBITS,
  597.                                         GA_Disabled,    TRUE,
  598.                                         GTCY_Active,    0,
  599.                                     TAG_DONE);
  600.  
  601.                                     LT_SetAttributes(Handle,GAD_DATABITS,
  602.                                         GA_Disabled,    TRUE,
  603.                                         GTCY_Active,    1,
  604.                                     TAG_DONE);
  605.                                 }
  606.                                 else
  607.                                 {
  608.                                     LT_SetAttributes(Handle,GAD_PARITY,
  609.                                         GA_Disabled,    FALSE,
  610.                                     TAG_DONE);
  611.  
  612.                                     LT_SetAttributes(Handle,GAD_STOPBITS,
  613.                                         GA_Disabled,    FALSE,
  614.                                     TAG_DONE);
  615.  
  616.                                     LT_SetAttributes(Handle,GAD_DATABITS,
  617.                                         GA_Disabled,    FALSE,
  618.                                     TAG_DONE);
  619.                                 }
  620.  
  621.                                 break;
  622.  
  623.                             case GAD_DIRECT_CONNECTION:
  624.  
  625.                                 LT_SetAttributes(Handle,GAD_CHECK_CARRIER,
  626.                                     GA_Disabled,    MsgCode,
  627.                                 TAG_DONE);
  628.  
  629.                                 break;
  630.  
  631.                             case GAD_USE:
  632.  
  633.                                 LT_UpdateStrings(Handle);
  634.  
  635. /*                                LocalConfig -> SerialConfig -> BaudRate = BaudRates[Rate];*/
  636.                                 LocalConfig -> SerialConfig -> SerialBufferSize = Sizes[Size];
  637.                                 LocalConfig -> SerialConfig -> Quantum = Sizes[Quantum];
  638.                                 LocalConfig -> SerialConfig -> BitsPerChar = Bits + 7;
  639.                                 LocalConfig -> SerialConfig -> StopBits = StopBits + 1;
  640.  
  641.                                 Done = TRUE;
  642.                                 break;
  643.  
  644.                             case GAD_CANCEL:
  645.  
  646.                                 SaveConfig(PrivateConfig,LocalConfig);
  647.  
  648.                                 Cancel = Done = TRUE;
  649.                                 break;
  650.  
  651.                             case GAD_DEFAULT:
  652.  
  653.                                 *Default = TRUE;
  654.  
  655.                                 Done = TRUE;
  656.                                 break;
  657.  
  658.                             case GAD_DEVICE:
  659.  
  660.                                 FindLibDev(PanelWindow,LT_GetString(Handle,MsgGadget -> GadgetID),NT_DEVICE,NULL);
  661.                                 break;
  662.                         }
  663.                     }
  664.  
  665.                     if(MsgClass == IDCMP_IDCMPUPDATE && MsgGadget -> GadgetID == GAD_DEVICE)
  666.                     {
  667.                         LT_LockWindow(PanelWindow);
  668.  
  669.                         strcpy(DummyBuffer,(STRPTR)LT_GetAttributes(Handle,GAD_DEVICE));
  670.                         strcpy(SharedBuffer,DummyBuffer);
  671.  
  672.                         if(PickFile(PanelWindow,"Devs:","#?.device",LocaleString(MSG_SERIALPANEL_SELECT_DEVICE_TXT),SharedBuffer,NT_DEVICE))
  673.                         {
  674.                             if(Stricmp(DummyBuffer,SharedBuffer))
  675.                             {
  676.                                 LT_SetAttributes(Handle,GAD_DEVICE,GTST_String,SharedBuffer,TAG_DONE);
  677.  
  678.                                 FindLibDev(PanelWindow,SharedBuffer,NT_DEVICE,NULL);
  679.                             }
  680.                         }
  681.  
  682.                         LT_UnlockWindow(PanelWindow);
  683.  
  684.                         LT_ShowWindow(Handle,TRUE);
  685.                     }
  686.                 }
  687.             }
  688.             while(!Done);
  689.  
  690.             PopWindow();
  691.         }
  692.  
  693.         LT_DeleteHandle(Handle);
  694.     }
  695.  
  696.     if(Config -> MiscConfig -> ProtectiveMode && !Cancel)
  697.     {
  698.         if(LocalConfig -> SerialConfig -> BaudRate >= 4800 && LocalConfig -> SerialConfig -> HandshakingProtocol == HANDSHAKING_NONE && !LocalConfig -> SerialConfig -> DirectConnection)
  699.         {
  700.             if(MyEasyRequest(Window,LocaleString(MSG_NO_RTSCTS_TXT),LocaleString(MSG_GLOBAL_YES_NO_TXT),LocalConfig -> SerialConfig -> BaudRate))
  701.                 LocalConfig -> SerialConfig -> HandshakingProtocol = HANDSHAKING_RTSCTS_DSR;
  702.         }
  703.     }
  704.  
  705.     if(Default)
  706.         return((BYTE)(!Cancel));
  707.     else
  708.         return((BYTE)memcmp(PrivateConfig -> SerialConfig,LocalConfig -> SerialConfig,sizeof(struct SerialSettings)));
  709. }
  710.